package net.isawesum;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Properties;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;


public class Main extends JFrame implements ActionListener, Runnable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -752107270498472781L;
	/**
	 * 
	 */

	public boolean stop = false;
    public Properties params;
    public JTabbedPane tab;
    public String script;
    public JFrame frame;
    public Class<?> client;
    public Applet rs;

    public Main() {
	new RSLoad();
	System.out.println("Created by Denver(Sub - denver@isawesum.net)");
	CreateGUI();
    }

    public void CreateGUI() {
	frame = new JFrame("RSLite");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setSize(790, 590);
	frame.setVisible(true);

	JMenuBar jmenubar = new JMenuBar();

	JMenu jmenu1 = new JMenu("File");
	JMenuItem jmenuitem1 = new JMenuItem("About");
	JMenuItem jmenuitem2 = new JMenuItem("New Tab");
	JMenuItem jmenuitem3 = new JMenuItem("Close Tab");
	JMenuItem jmenuitem4 = new JMenuItem("Exit");
	jmenu1.add(jmenuitem1);
	jmenu1.add(jmenuitem2);
	jmenu1.add(jmenuitem3);
	jmenu1.add(jmenuitem4);
	jmenubar.add(jmenu1);

	
	

	jmenuitem1.addActionListener(this);
	jmenuitem2.addActionListener(this);
	jmenuitem3.addActionListener(this);
	jmenuitem4.addActionListener(this);
	
	frame.add(jmenubar,"North");

	tab = new JTabbedPane();
	JPanel panel = new JPanel();
	panel.setPreferredSize(new Dimension(768,560));
	panel.setLayout(new BorderLayout());
	panel.add(new RSLoad().applet, BorderLayout.CENTER);
	panel.setSize(700,565);
	tab.add("RSLite",panel);
	frame.add(tab);
    }

    public void actionPerformed(ActionEvent actionevent) {
	String s = actionevent.getActionCommand();
	if(s != null) {
		if(s.equalsIgnoreCase("Exit"))
			System.exit(0);
		if(s.equalsIgnoreCase("About"))
			JOptionPane.showMessageDialog(null, "RsLite by Denver(Sub - denver@isawesum.net)");
	
		
		if(s.equalsIgnoreCase("New Tab")) {
			JPanel panel2 = new JPanel();
			panel2.setPreferredSize(new Dimension(768,560));
			panel2.setLayout(new BorderLayout());
			panel2.add(new RSLoad().applet, BorderLayout.CENTER);
			panel2.setSize(700,565);
			tab.add("DosBot",panel2);
			frame.add(tab);
		}
		if(s.equalsIgnoreCase("Close Tab")) {
		}
	}
    }

    Main (String s) {
	script = s;
    }

    public void run() {
	try {
		@SuppressWarnings("unused")
		Class<?> class1 = Class.forName(script);
		System.out.println("Starting "+script+"...");
		System.out.println(script+" successfully executed.");
        } catch(Exception e) {
		System.out.println(script+" is not a valid Script.");
        }
    }

    public static void main(String args[]) {
	new Main();
    }
}
